// 阻止内存泄漏
require("events").EventEmitter.defaultMaxListeners = 0;
module.exports = {
	// 懒加载配置
	chainWebpack: (config) => {
		// 删除带有prefetch的link文件
		config.plugins.delete("prefetch");
		// 设置首次加载页面的title信息
		config.plugin("html").tap((args) => {
			args[0].title = "酷狗音乐 - 就是歌多";
			return args;
		});
	},
	devServer: {
		proxy: {
			// 登录和注册
			"/api-userInfo": {
				target: "http://127.0.0.1:10086",
				changeOrigin: true,
				pathRewrite: {
					"^/api-userInfo": "",
				},
			},
			// 搜索视频与专辑
			"/api-search-video": {
				target: "http://msearch.kugou.com/api/v3/search",
				changeOrigin: true,
				pathRewrite: {
					"^/api-search-video": "",
				},
			},
			// 搜索歌曲与歌单
			"/api-search-song": {
				target: "http://mobilecdnbj.kugou.com/api/v3/search",
				changeOrigin: true,
				pathRewrite: {
					"^/api-search-song": "",
				},
			},
			// 歌曲详情
			"/api-music": {
				target: "http://api.lmwljz.com/song",
				changeOrigin: true,
				pathRewrite: {
					"^/api-music": "",
				},
			},
			// 电台
			"/api-radio": {
				target: "http://musicapi.leanapp.cn/dj/program?rid=336355127",
				changeOrigin: true,
				pathRewrite: {
					"/api-radio": "",
				},
			},
			// 获取歌曲的MP3链接和歌词
			"/api-mp3": {
				target: "http://localhost:10000",
				changeOrigin: true,
				pathRewrite: {
					"^/api-mp3": "",
				},
			},
			// 获取歌曲ID
			"/api-song-details": {
				target: "http://musicapi.leanapp.cn",
				changeOrigin: true,
				pathRewrite: {
					"^/api-song-details": "",
				},
			},
			// 分类歌单
			"/api-classify-song-list": {
				target: "http://mobilecdnbj.kugou.com/api/v3/tag/specialList",
				changeOrigin: true,
				pathRewrite: {
					"^/api-classify-song-list": "",
				},
			},
			// 新歌
			"/api-new-song": {
				target: "http://mobilecdnbj.kugou.com/api/v3/rank/newsong",
				changeOrigin: true,
				pathRewrite: {
					"^/api-new-song": "",
				},
			},
			// 热门歌手
			"/api-hot-singer": {
				target: "http://mobilecdnbj.kugou.com/api/v5/singer/list",
				changeOrigin: true,
				pathRewrite: {
					"^/api-hot-singer": "",
				},
			},
			// 热门歌单
			"/api-hot-song-list": {
				target:
					"http://mobilecdnbj.kugou.com/api/v5/special/recommend?recommend_expire=0&sign=52186982747e1404d426fa3f2a1e8ee4&plat=0&uid=0&version=9108&page=1&area_code=1&appid=1005&mid=286974383886022203545511837994020015101&_t=1545746286",
				changeOrigin: true,
				pathRewrite: {
					"^/api-hot-song-list": "",
				},
			},
			// 专辑信息
			"/api-album": {
				target: "http://mobilecdn.kugou.com/api/v3/album",
				changeOrigin: true,
				pathRewrite: {
					"^/api-album": "",
				},
			},
			// 歌单
			"/api-song-list": {
				target: "http://m.kugou.com/plist",
				changeOrigin: true,
				pathRewrite: {
					"^/api-song-list": "",
				},
			},
			// 视频mv详情
			"/api-video-details": {
				target: " http://m.kugou.com/app/i",
				changeOrigin: true,
				pathRewrite: {
					"^/api-video-details": "",
				},
			},
			// 视频mv
			"/api-video": {
				target: "http://mobileservice.kugou.com/api/v5/video",
				changeOrigin: true,
				pathRewrite: {
					"^/api-video": "",
				},
			},
			// 歌手详情
			"/api-singer-details": {
				target: "http://mobilecdnbj.kugou.com/api/v3/singer",
				changeOrigin: true,
				pathRewrite: {
					"^/api-singer-details": "",
				},
			},
			// 歌手
			"/api-singer": {
				target: "http://m.kugou.com",
				changeOrigin: true,
				pathRewrite: {
					"^/api-singer": "/",
				},
			},
			// 直播
			"/api-live": {
				target:
					"http://bjacshow.kugou.com/show7/json/v2/cdn/index/live/list?platform=1&sign=0e2e8fb44383458f&version=9108&pageSize=50&gaodeCode=0371&channel=10&page=1&longitude=113.69&std_plat=5&latitude=34.8",
				changeOrigin: true,
			},
			// 分类专区
			"/api-classify": {
				target:
					"http://mobilecdnbj.kugou.com/api/v3/tag/list?pid=0&apiver=2&plat=0",
				changeOrigin: true,
			},
			// 排行榜详情
			"/api-details": {
				target: "http://m.kugou.com/rank/info/",
				changeOrigin: true,
			},
			// 排行榜分类
			"/api": {
				target:
					"http://mobilecdnbj.kugou.com/api/v3/rank/list?version=9108&plat=0&showtype=2&parentid=0&apiver=6&area_code=1&withsong=1&with_res_tag=1",
				changeOrigin: true,
			},
		},
	},
};
